package com.truongnha.clienttn.business.model;
import org.json.JSONException;
import org.json.JSONObject;

import com.truongnha.clienttn.data.entity.AttendEntity;

//{"type": "P", "sent": false, "time": "03/12/2012"}
public class AttendModel {
	private String type;
	private Boolean sent;
	private String time;

	public AttendModel(String type, String sent, String time) {
		this.type = type;
		if ("false".equals(sent))
			this.sent = false;
		else
			this.sent = true;
		//this.sent = sent;
		this.time = time;
	}
	public AttendModel(AttendEntity attendEntity) {
		this.type = attendEntity.getType();
		this.time = attendEntity.getTime();
		if (attendEntity.getSent().equals("false"))
			this.sent = false ;
		else
			this.sent = true;	
	}
	public AttendModel(JSONObject obj) {
		try {
			type = obj.getString("type");
			if (obj.getString("sent").equals("false"))
				sent = false;
			else
				sent = true;
			time = obj.getString("time");
		} catch (JSONException e) {
			e.printStackTrace();
		}
	}

	public int getType() {
		if (type.equals("K"))
			return 3;
		if (type.equals("M"))
			return 2;
		if (type.equals("P"))
			return 1;
		else
			return 0;
	}

	public Boolean getSent() {
		return sent;
	}

	public String getTime() {
		return time;
	}
}